package cn.like.util;

import cn.hutool.core.bean.copier.BeanCopier;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.ObjectUtil;

/**
 * description: bean copy 工具类
 *
 * @author like 980650920@qq.com
 * @date 2021-07-11 23:18:06
 * @see BeanUtil
 */
public class BeanUtil extends cn.hutool.core.bean.BeanUtil {

    /**
     * 复制 bean
     *
     * @param source      源
     * @param dest        目标对象
     * @param copyOptions 复制选项
     * @return {@link T} dest
     * @see cn.hutool.core.bean.BeanUtil#copyProperties(Object, Object, boolean)
     */
    public static <T> T copy(Object source, T dest, CopyOptions copyOptions) {
        return BeanCopier.create(source, dest, ObjectUtil.defaultIfNull(copyOptions, CopyOptions.create())).copy();
    }

    public static <T> T copy(Object source, T dest) {
        return copy(source, dest, null);
    }
}
